﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;
using YasharEl.Infrastructure.Core.EntityModel.Personification;
using YasharEl.Infrastructure.Core.Personification;

namespace YasharEl.Infrastructure.Core.PersistenceModel.NHibernate.Personification.Mappings
{
    public class PersonEntityMap : ClassMap<PersonEntity>
    {
        public PersonEntityMap()
        {
            Table("Persons");
            Id(e => e.PersonId)
                .Column("PERSON_ID")
                .GeneratedBy.Identity();
            Component<Name>(e => e.PersonName,
                nameEntity =>
                {
                    nameEntity.Access.Property();
                    nameEntity.Map(n => n.Firstname)
                        .Column("FIRST_NAME")
                        .Not.Nullable();
                    nameEntity.Map(n => n.Lastname)
                        .Column("LAST_NAME")
                        .Not.Nullable();
                    nameEntity.Map(n => n.MiddleName)
                        .Column("MIDDLE_NAME")
                        .Nullable();
                }
            );
        }
    }
}
